<?php

/**
 * InvoiceAmounts form.
 *
 * @package    form
 * @subpackage invoice_amounts
 * @version    SVN: $Id: sfPropelFormTemplate.php 6174 2007-11-27 06:22:40Z fabien $
 */
class InvoiceAmountsForm extends BaseInvoiceAmountsForm
{
  public function configure()
  {   
    if($this->isNew()){
      $this->validatorSchema['invoice_iden'] = new sfValidatorString(array('required' => true));
      $this->validatorSchema['amount_iden'] = new sfValidatorString(array('required' => true));
    }
      
    $this->widgetSchema['description']->setAttribute('size',30);
    $this->widgetSchema['amount']->setAttribute('size',10);
    $this->widgetSchema['discount1']->setAttribute('size',1);
    $this->validatorSchema['discount1']->setOption('min',0);
    $this->widgetSchema['discount2']->setAttribute('size',1);
    $this->validatorSchema['discount2']->setOption('min',0);
    $this->widgetSchema['discount3']->setAttribute('size',1);
    $this->validatorSchema['discount3']->setOption('min',0);
    $this->widgetSchema['discount4']->setAttribute('size',1);
    $this->validatorSchema['discount4']->setOption('min',0);
    $this->widgetSchema->setLabels(
      array(
        'description'=>'Description',
        'amount'=>'Amount',
        'discount1'=>'D1',
        'discount2'=>'D2',
        'discount3'=>'D3',
        'discount4'=>'D4',
      )
    );
  }
  
  public function setInvoiceIdenDefault($i){
    $this->setDefault('invoice_iden',$i);
  }
  
  public function getUrl(){
    if($this->isNew())
      return 'invoice/insertInvoiceAmounts';
    else
      return 'invoice/updateInvoiceAmounts';
      
  }
  
}
